#include <iostream>
#include <string>

int const maxn = 27;
int a[maxn];
int n, m;

int main()
{
	std::cin >> n >> m;
	std::string s;
	std::cin >> s;

	for (int i = 0; i < 26; i++) a[i] = i;
	for (int i = 0; i < m; i++) {
		char c1, c2;
		std::cin >> c1 >> c2;
		int ch1 = c1 - 'a', ch2 = c2 - 'a';
		int p1 = 0, p2 = 0;
//		std::cout << "-->" << ch1 << ' ' << p1 << ' ' << ch2 << ' ' << p2 << '\n';
		for (; p1 < 26; p1++) if (a[p1] == ch1) break;
		for (; p2 < 26; p2++) if (a[p2] == ch2) break;
		a[p1] = ch2; a[p2] = ch1;
	}
	for (int i = 0; i < (int)s.size(); i++)
		std::cout << char(a[(int)s[i] - 'a'] + 'a');
	std::cout << '\n';
}

